package com.produce.common.util;

import java.security.MessageDigest;
import java.util.ResourceBundle;

public class Md5Helper {
	 public static String md5Str(String str)
	  {
		String MD5StrartStirng= ResourceBundle.getBundle("sysconfig").getString("MD5StrartStirng").trim();
//		str = MD5StrartStirng + str +MD5StrartStirng;
		//执行ggs的加密方法
		str = str +MD5StrartStirng;
	    try
	    {
	      MessageDigest md = MessageDigest.getInstance("MD5");
	      str = (str == null) ? "" : str;
	      md.update(str.getBytes("utf-8"));
	      byte[] b = md.digest();
	      StringBuffer buf = new StringBuffer();
	      for (int offset = 0; offset < b.length; ++offset) {
	        int i = b[offset];
	        if (i < 0)
	          i += 256;
	        if (i < 16)
	          buf.append("0");
	        buf.append(Integer.toHexString(i));
	      }
	      str = buf.toString();
	    } catch (Exception e) {
	      e.printStackTrace();
	    }
	    return str;
	  }
}
